Skip to content

fix: 'PaintByExampleImageEncoder' object has no attribute 'all_tied_w…#13252

Merged
yiyixuxu merged 6 commits intohuggingface:mainfrom
kaixuanliu:paint_by_example
Mar 19, 2026
Merged

fix: 'PaintByExampleImageEncoder' object has no attribute 'all_tied_w…#13252
yiyixuxu merged 6 commits intohuggingface:mainfrom
kaixuanliu:paint_by_example

Conversation

@kaixuanliu
Copy link
Copy Markdown
Contributor

@yiyixuxu and @asomoza, pls help review, thx! This PR fixes bug for following sample code:

import torch
from diffusers import PaintByExamplePipeline
from PIL import Image, ImageDraw

# Load the pipeline
pipe = PaintByExamplePipeline.from_pretrained(
    "Fantasy-Studio/Paint-by-Example",
    torch_dtype=torch.float16,
)
pipe.to("cuda")

# 1. Source image (the image to be edited)
image = Image.new("RGB", (512, 512), color="white")

# 2. Mask image (white = replace, black = keep)
mask = Image.new("RGB", (512, 512), color="black")
draw = ImageDraw.Draw(mask)
draw.rectangle([128, 128, 384, 384], fill="white")

# 3. Example image (reference content to paint in masked area)
example_image = Image.new("RGB", (256, 256), color="blue")

# Run inference
output = pipe(
    image=image,
    mask_image=mask,
    example_image=example_image,
    num_inference_steps=30,
).images[0]

output.save("output.png")

Before this PR, it will throw error:

Traceback (most recent call last):
  File "/root/upstream/diffusers/test.py", line 6, in <module>                                                                     pipe = PaintByExamplePipeline.from_pretrained(                                                                               File "/usr/local/lib/python3.10/dist-packages/huggingface_hub/utils/_validators.py", line 89, in _inner_fn
    return fn(*args, **kwargs)
  File "/root/upstream/diffusers/src/diffusers/pipelines/pipeline_utils.py", line 1049, in from_pretrained
    loaded_sub_model = load_sub_model(                                                                                           File "/root/upstream/diffusers/src/diffusers/pipelines/pipeline_loading_utils.py", line 885, in load_sub_model
    loaded_sub_model = load_method(os.path.join(cached_folder, name), **loading_kwargs)
  File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py", line 4138, in from_pretrained
    loading_info = cls._finalize_model_loading(model, load_config, loading_info)
  File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py", line 4279, in _finalize_model_loading
    model.mark_tied_weights_as_initialized(loading_info)
  File "/usr/local/lib/python3.10/dist-packages/transformers/modeling_utils.py", line 4598, in mark_tied_weights_as_initialized
    for tied_param in self.all_tied_weights_keys.keys():
  File "/usr/local/lib/python3.10/dist-packages/torch/nn/modules/module.py", line 1965, in __getattr__
    raise AttributeError(
AttributeError: 'PaintByExampleImageEncoder' object has no attribute 'all_tied_weights_keys'. Did you mean: '_tied_weights_keys
'?

…eights_keys'

Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
Signed-off-by: Liu, Kaixuan <kaixuan.liu@intel.com>
@kaixuanliu
Copy link
Copy Markdown
Contributor Author

And the same case w/ LDMBertModel

@kaixuanliu
Copy link
Copy Markdown
Contributor Author

@DN6 Hi, can you help review? Thx!

Copy link
Copy Markdown
Member

@asomoza asomoza left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@HuggingFaceDocBuilderDev
Copy link
Copy Markdown

The docs for this PR live here. All of your documentation changes will be reflected on that endpoint. The docs are available until 30 days after the last update.

@kaixuanliu
Copy link
Copy Markdown
Contributor Author

@asomoza @yiyixuxu Hi, can this PR be merged?

@yiyixuxu
Copy link
Copy Markdown
Collaborator

hey @kaixuanliu
i will merge this since the change is minimum, these are deprected pipelines though we are not actively maintaining

@yiyixuxu yiyixuxu merged commit 6761336 into huggingface:main Mar 19, 2026
11 checks passed
@yao-matrix
Copy link
Copy Markdown
Contributor

@yiyixuxu , does diffusers has some deprecation policy like move the deprecated models into a dedicate deprecated folder or other? As platform vendors like Intel, we want to make sure Intel GPU support all valid pipelines maintained by diffusers, so a good discrimination should help here. Thx.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants